package cpi;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.io.*;

@MapperScan("cpi.dao")
@SpringBootApplication
@EnableTransactionManagement//事务管理器
public class SpringBootApp {
    public static void main(String[] args) throws IOException {
//        File batFile = new File("/datagear-3.2.0");
//        batFile.getAbsolutePath();
//        String cmd = "cmd /c start java -jar  E:\\backup3\\大学学习资料\\大三\\2019级院企实训方案\\tedu\\code\\cpi\\cpi-backend\\src\\main\\resources\\datagear-3.2.0\\datagear-3.2.0.jar";
//        Runtime.getRuntime().exec(cmd);
//        File batFile = new File("/datagear-3.2.0/startup.bat");
//        callCmd("/datagear-3.2.0/startup.bat");
        //启动内部tomcat
        SpringApplication.run(SpringBootApp.class);
    }
    private static void  callCmd(String locationCmd){
        StringBuilder sb = new StringBuilder();
        try {
            Process child = Runtime.getRuntime().exec(locationCmd);
            InputStream in = child.getInputStream();
            BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(in));
            String line;
            while((line=bufferedReader.readLine())!=null)
            {
                sb.append(line + "\n");
            }
            in.close();
            try {
                child.waitFor();
            } catch (InterruptedException e) {
                System.out.println(e);
            }
            System.out.println("sb:" + sb.toString());
            System.out.println("callCmd execute finished");
        } catch (IOException e) {
            System.out.println(e);
        }
    }
}
